package cn.cew.bytespyserver.socket;

import lombok.SneakyThrows;
import lombok.extern.apachecommons.CommonsLog;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author chenenwei
 * @version 1.0.0
 * @description TODO
 * @createTime 2022-10-16 11:52:00
 */
@Slf4j
@Component
public class SocketRunner implements CommandLineRunner {

    @Value("${agent.socket.port:9999}")
    private int port;

    @Resource
    private AgentServerSocket agentServerSocket;

    @Resource
    private WebsocketServer websocketServer;

    @Override
    public void run(String... args) {
        try {
            agentServerSocket.start(port);
            log.info("【Socket服务启动成功】端口：{}", port);
        } catch (Exception e) {
            log.error("【Socket服务启动失败】", e);
        }
    }

}
